/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controlador.Service.Compras;

import Controlador.Bean.Almacen.Producto;
import Controlador.Bean.Compras.CatalogoData;
import Controlador.Bean.Compras.Proveedor;
import Data.config.SessionFac;
import java.util.HashMap;
import java.util.List;
import org.apache.ibatis.session.SqlSession;

/**
 *
 * @author LiziTa
 */
public class ServicioCatalogo {
    
    
     public void guardar(CatalogoData catalogo){
         try(  SqlSession sqlsession= SessionFac.SessionFactory().openSession()){
        //proveedor.setIdProveedor(obtenerIdSiguiente(proveedor.getIdProveedor()));
        sqlsession.insert("Data.Compras.ServicioCatalogo.guardar", catalogo);
        sqlsession.commit();
        sqlsession.close();
      
        }catch(Exception ex){
            ex.printStackTrace();
        }
        
}
     public List<CatalogoData> seleccionarCatalogo(String prov,String prod){
         SqlSession sqlsession= SessionFac.SessionFactory().openSession();
          HashMap<String, String> hm = new HashMap<>();
          hm.put("id", "%"+prov+"%");
           hm.put("prod", "%"+prod+"%");
          List<CatalogoData> data = (List)sqlsession.selectList("Data.Compras.ServicioCatalogo.seleccionarCatalogo", hm);
        sqlsession.close();
        return data;
    }
     
    

}